package br.com.fiap.si;

import java.util.ArrayList;

import javax.swing.JOptionPane;

import br.com.fiap.si.Beans.Rm;

public class TesteCaminho extends Operacoes {
	public static String caminho = "";
	
	public static void main(String[] args) {
		Rm n0 = new Rm(0);
		Rm n1 = new Rm(1);
		Rm n2 = new Rm(2);
		Rm n3 = new Rm(3);
		Rm n4 = new Rm(4);
		Rm n5 = new Rm(5);
		Rm n6 = new Rm(6);
		Rm n7 = new Rm(7);
		Rm n8 = new Rm(8);
		
		Rm listaAlunos[] = new Rm[9];
		
		listaAlunos[0] = n0; 
		listaAlunos[1] = n1; 
		listaAlunos[2] = n2; 
		listaAlunos[3] = n3; 
		listaAlunos[4] = n4; 
		listaAlunos[5] = n5; 
		listaAlunos[6] = n6; 
		listaAlunos[7] = n7;
		listaAlunos[8] = n8;
		
		n0.rms[0]= n1;
		n0.rms[1]= n8;
		
		n1.rms[0]= n0;
		n1.rms[1]= n5;
		
		n2.rms[0]= n3;
		n2.rms[1]= n6;
		n2.rms[2]= n7;
		
		n3.rms[0]= n2;
		
		n4.rms[0]= n5;
		n4.rms[1]= n8;
		
		n5.rms[0]= n1;
		n5.rms[1]= n4;
		n5.rms[2]= n6;
		n5.rms[3]= n8;
		
		n6.rms[0]= n2;
		n6.rms[1]= n5;
		n6.rms[2]= n7;
		
		n7.rms[0]= n2;
		n7.rms[1]= n6;
		
		n8.rms[0]= n0;
		n8.rms[1]= n4;
		n8.rms[2]= n5;
		
		int cont = 0;
		ArrayList<Rm> fila = new ArrayList<Rm>();
		
		buscaProfund(n0, 0);
		
		for (Rm x : listaAlunos) {
			if (x.temFilho == false) {
				fila.add(x);
			}
		}
		for(cont = 0; cont < fila.size(); cont++) {
			mostraCaminho(fila.get(cont));
			caminho = "\n" + caminho; 
        }
		JOptionPane.showMessageDialog(null, caminho);
	}
}
